<script type="text/javascript">
    function jqxFixColumns(columns){
        columns['Status'].createeditor=function (row, cellvalue, editor) {
                var dataSource = ['New', 'Confirmed', 'Shipping','Canceled','Finished'];
                editor.jqxDropDownList({source: dataSource });
        }
        return columns;
    }
    function handleEvent_jqxGrid(jqxgrid){
        jqxgrid.bind('cellendedit', function (event) {
            try{
                var args = event.args;
                var Column = args.datafield ,Row = args.rowindex,Value = args.value;
                var Data=jqxgrid.jqxGrid('getrowdata', Row);
                var ID=Data.ID;
                if(ID==undefined || ID==""){
                    return;
                }
                switch(Column){
                    case "Paypal":
                        var url,data;
                        url="{{base_url()}}APanel/fe548e5a964095e7c80cd8d3721be2ef/columnUpdate/{{$token}}/Paypal";
                        data={
                            ID      :   ID,
                            Value   :   Value
                        }
                        isrunning=true;
                        jqxAjax(url,data,function(result){
                            isrunning=false;
                            if(result.code>=0){

                            }else{
                                ShowNoticeDialogMessage(result.msg);
                            }
                        });
                        break;
                    case "Status":
                        if(Data.Status!=Value){
                            myjqxGrid.StatusChange(ID,Value);
                        }
                        break;
                    case "OrderDate":
                        var newDate=Data.OrderDate.toLocaleDateString();
                        Value=Value.toLocaleDateString();
                        if(newDate!=Value){
                            ShowNoticeDialogMessage(ID+":"+Value);
                        }
                        break;
                    default:
                    ShowNoticeDialogMessage("Unkown this cell. Maybe 'editable' of this colums is 'off'"); 
                }
            }catch(e){
                ShowNoticeDialogMessage("Error:"+e.message);
                console.log("Error:"+e.message);
            }
        });
    }
    
</script>